
#include <cstdio>
#include <BMatrix>
#include <BOpenGL>
#include "IGLState.h"

#ifdef _LINUX_
#include <GL/glx.h>
#endif

#ifdef _WINDOWS_SYSTEM_
#include <Windows.h>
#undef min
#undef max
#undef far
#undef near
#endif

using namespace BWE;

BArray<GLuint>		UnusedTextureObjects;
BArray<GLuint>		UnusedFrameBufferObjects;
BArray<GLuint>		UnusedRenderBufferObjects;
BArray<GLuint>		UnusedProgramObjects;
BArray<GLuint>		UnusedShaderObjects;
BArray<GLuint>		UnusedListObjects;

#define GLAPI_FUNC(function) BWEAPI api_##function function = 0;

#ifdef _LINUX_
#define LOADGLAPI(function) function = (api_##function)glXGetProcAddress((const GLubyte*)#function);
/*GL_VERSION_1_1*/
GLAPI_FUNC(glAccum)
GLAPI_FUNC(glAlphaFunc)
GLAPI_FUNC(glAreTexturesResident)
GLAPI_FUNC(glArrayElement)
GLAPI_FUNC(glBegin)
GLAPI_FUNC(glBindTexture)
GLAPI_FUNC(glBitmap)
GLAPI_FUNC(glBlendFunc)
GLAPI_FUNC(glCallList)
GLAPI_FUNC(glCallLists)
GLAPI_FUNC(glClear)
GLAPI_FUNC(glClearAccum)
GLAPI_FUNC(glClearColor)
GLAPI_FUNC(glClearDepth)
GLAPI_FUNC(glClearIndex)
GLAPI_FUNC(glClearStencil)
GLAPI_FUNC(glClipPlane)
GLAPI_FUNC(glColor3b)
GLAPI_FUNC(glColor3bv)
GLAPI_FUNC(glColor3d)
GLAPI_FUNC(glColor3dv)
GLAPI_FUNC(glColor3f)
GLAPI_FUNC(glColor3fv)
GLAPI_FUNC(glColor3i)
GLAPI_FUNC(glColor3iv)
GLAPI_FUNC(glColor3s)
GLAPI_FUNC(glColor3sv)
GLAPI_FUNC(glColor3ub)
GLAPI_FUNC(glColor3ubv)
GLAPI_FUNC(glColor3ui)
GLAPI_FUNC(glColor3uiv)
GLAPI_FUNC(glColor3us)
GLAPI_FUNC(glColor3usv)
GLAPI_FUNC(glColor4b)
GLAPI_FUNC(glColor4bv)
GLAPI_FUNC(glColor4d)
GLAPI_FUNC(glColor4dv)
GLAPI_FUNC(glColor4f)
GLAPI_FUNC(glColor4fv)
GLAPI_FUNC(glColor4i)
GLAPI_FUNC(glColor4iv)
GLAPI_FUNC(glColor4s)
GLAPI_FUNC(glColor4sv)
GLAPI_FUNC(glColor4ub)
GLAPI_FUNC(glColor4ubv)
GLAPI_FUNC(glColor4ui)
GLAPI_FUNC(glColor4uiv)
GLAPI_FUNC(glColor4us)
GLAPI_FUNC(glColor4usv)
GLAPI_FUNC(glColorMask)
GLAPI_FUNC(glColorMaterial)
GLAPI_FUNC(glColorPointer)
GLAPI_FUNC(glCopyPixels)
GLAPI_FUNC(glCopyTexImage1D)
GLAPI_FUNC(glCopyTexImage2D)
GLAPI_FUNC(glCopyTexSubImage1D)
GLAPI_FUNC(glCopyTexSubImage2D)
GLAPI_FUNC(glCullFace)
GLAPI_FUNC(glDeleteLists)
GLAPI_FUNC(glDeleteTextures)
GLAPI_FUNC(glDepthFunc)
GLAPI_FUNC(glDepthMask)
GLAPI_FUNC(glDepthRange)
GLAPI_FUNC(glDisable)
GLAPI_FUNC(glDisableClientState)
GLAPI_FUNC(glDrawArrays)
GLAPI_FUNC(glDrawBuffer)
GLAPI_FUNC(glDrawElements)
GLAPI_FUNC(glDrawPixels)
GLAPI_FUNC(glEdgeFlag)
GLAPI_FUNC(glEdgeFlagPointer)
GLAPI_FUNC(glEdgeFlagv)
GLAPI_FUNC(glEnable)
GLAPI_FUNC(glEnableClientState)
GLAPI_FUNC(glEnd)
GLAPI_FUNC(glEndList)
GLAPI_FUNC(glEvalCoord1d)
GLAPI_FUNC(glEvalCoord1dv)
GLAPI_FUNC(glEvalCoord1f)
GLAPI_FUNC(glEvalCoord1fv)
GLAPI_FUNC(glEvalCoord2d)
GLAPI_FUNC(glEvalCoord2dv)
GLAPI_FUNC(glEvalCoord2f)
GLAPI_FUNC(glEvalCoord2fv)
GLAPI_FUNC(glEvalMesh1)
GLAPI_FUNC(glEvalMesh2)
GLAPI_FUNC(glEvalPoint1)
GLAPI_FUNC(glEvalPoint2)
GLAPI_FUNC(glFeedbackBuffer)
GLAPI_FUNC(glFinish)
GLAPI_FUNC(glFlush)
GLAPI_FUNC(glFogf)
GLAPI_FUNC(glFogfv)
GLAPI_FUNC(glFogi)
GLAPI_FUNC(glFogiv)
GLAPI_FUNC(glFrontFace)
GLAPI_FUNC(glFrustum)
GLAPI_FUNC(glGenLists)
GLAPI_FUNC(glGenTextures)
GLAPI_FUNC(glGetBooleanv)
GLAPI_FUNC(glGetClipPlane)
GLAPI_FUNC(glGetDoublev)
GLAPI_FUNC(glGetError)
GLAPI_FUNC(glGetFloatv)
GLAPI_FUNC(glGetIntegerv)
GLAPI_FUNC(glGetLightfv)
GLAPI_FUNC(glGetLightiv)
GLAPI_FUNC(glGetMapdv)
GLAPI_FUNC(glGetMapfv)
GLAPI_FUNC(glGetMapiv)
GLAPI_FUNC(glGetMaterialfv)
GLAPI_FUNC(glGetMaterialiv)
GLAPI_FUNC(glGetPixelMapfv)
GLAPI_FUNC(glGetPixelMapuiv)
GLAPI_FUNC(glGetPixelMapusv)
GLAPI_FUNC(glGetPointerv)
GLAPI_FUNC(glGetPolygonStipple)
GLAPI_FUNC(glGetString)
GLAPI_FUNC(glGetTexEnvfv)
GLAPI_FUNC(glGetTexEnviv)
GLAPI_FUNC(glGetTexGendv)
GLAPI_FUNC(glGetTexGenfv)
GLAPI_FUNC(glGetTexGeniv)
GLAPI_FUNC(glGetTexImage)
GLAPI_FUNC(glGetTexLevelParameterfv)
GLAPI_FUNC(glGetTexLevelParameteriv)
GLAPI_FUNC(glGetTexParameterfv)
GLAPI_FUNC(glGetTexParameteriv)
GLAPI_FUNC(glHint)
GLAPI_FUNC(glIndexMask)
GLAPI_FUNC(glIndexPointer)
GLAPI_FUNC(glIndexd)
GLAPI_FUNC(glIndexdv)
GLAPI_FUNC(glIndexf)
GLAPI_FUNC(glIndexfv)
GLAPI_FUNC(glIndexi)
GLAPI_FUNC(glIndexiv)
GLAPI_FUNC(glIndexs)
GLAPI_FUNC(glIndexsv)
GLAPI_FUNC(glIndexub)
GLAPI_FUNC(glIndexubv)
GLAPI_FUNC(glInitNames)
GLAPI_FUNC(glInterleavedArrays)
GLAPI_FUNC(glIsEnabled)
GLAPI_FUNC(glIsList)
GLAPI_FUNC(glIsTexture)
GLAPI_FUNC(glLightModelf)
GLAPI_FUNC(glLightModelfv)
GLAPI_FUNC(glLightModeli)
GLAPI_FUNC(glLightModeliv)
GLAPI_FUNC(glLightf)
GLAPI_FUNC(glLightfv)
GLAPI_FUNC(glLighti)
GLAPI_FUNC(glLightiv)
GLAPI_FUNC(glLineStipple)
GLAPI_FUNC(glLineWidth)
GLAPI_FUNC(glListBase)
GLAPI_FUNC(glLoadIdentity)
GLAPI_FUNC(glLoadMatrixd)
GLAPI_FUNC(glLoadMatrixf)
GLAPI_FUNC(glLoadName)
GLAPI_FUNC(glLogicOp)
GLAPI_FUNC(glMap1d)
GLAPI_FUNC(glMap1f)
GLAPI_FUNC(glMap2d)
GLAPI_FUNC(glMap2f)
GLAPI_FUNC(glMapGrid1d)
GLAPI_FUNC(glMapGrid1f)
GLAPI_FUNC(glMapGrid2d)
GLAPI_FUNC(glMapGrid2f)
GLAPI_FUNC(glMaterialf)
GLAPI_FUNC(glMaterialfv)
GLAPI_FUNC(glMateriali)
GLAPI_FUNC(glMaterialiv)
GLAPI_FUNC(glMatrixMode)
GLAPI_FUNC(glMultMatrixd)
GLAPI_FUNC(glMultMatrixf)
GLAPI_FUNC(glNewList)
GLAPI_FUNC(glNormal3b)
GLAPI_FUNC(glNormal3bv)
GLAPI_FUNC(glNormal3d)
GLAPI_FUNC(glNormal3dv)
GLAPI_FUNC(glNormal3f)
GLAPI_FUNC(glNormal3fv)
GLAPI_FUNC(glNormal3i)
GLAPI_FUNC(glNormal3iv)
GLAPI_FUNC(glNormal3s)
GLAPI_FUNC(glNormal3sv)
GLAPI_FUNC(glNormalPointer)
GLAPI_FUNC(glOrtho)
GLAPI_FUNC(glPassThrough)
GLAPI_FUNC(glPixelMapfv)
GLAPI_FUNC(glPixelMapuiv)
GLAPI_FUNC(glPixelMapusv)
GLAPI_FUNC(glPixelStoref)
GLAPI_FUNC(glPixelStorei)
GLAPI_FUNC(glPixelTransferf)
GLAPI_FUNC(glPixelTransferi)
GLAPI_FUNC(glPixelZoom)
GLAPI_FUNC(glPointSize)
GLAPI_FUNC(glPolygonMode)
GLAPI_FUNC(glPolygonOffset)
GLAPI_FUNC(glPolygonStipple)
GLAPI_FUNC(glPopAttrib)
GLAPI_FUNC(glPopClientAttrib)
GLAPI_FUNC(glPopMatrix)
GLAPI_FUNC(glPopName)
GLAPI_FUNC(glPrioritizeTextures)
GLAPI_FUNC(glPushAttrib)
GLAPI_FUNC(glPushClientAttrib)
GLAPI_FUNC(glPushMatrix)
GLAPI_FUNC(glPushName)
GLAPI_FUNC(glRasterPos2d)
GLAPI_FUNC(glRasterPos2dv)
GLAPI_FUNC(glRasterPos2f)
GLAPI_FUNC(glRasterPos2fv)
GLAPI_FUNC(glRasterPos2i)
GLAPI_FUNC(glRasterPos2iv)
GLAPI_FUNC(glRasterPos2s)
GLAPI_FUNC(glRasterPos2sv)
GLAPI_FUNC(glRasterPos3d)
GLAPI_FUNC(glRasterPos3dv)
GLAPI_FUNC(glRasterPos3f)
GLAPI_FUNC(glRasterPos3fv)
GLAPI_FUNC(glRasterPos3i)
GLAPI_FUNC(glRasterPos3iv)
GLAPI_FUNC(glRasterPos3s)
GLAPI_FUNC(glRasterPos3sv)
GLAPI_FUNC(glRasterPos4d)
GLAPI_FUNC(glRasterPos4dv)
GLAPI_FUNC(glRasterPos4f)
GLAPI_FUNC(glRasterPos4fv)
GLAPI_FUNC(glRasterPos4i)
GLAPI_FUNC(glRasterPos4iv)
GLAPI_FUNC(glRasterPos4s)
GLAPI_FUNC(glRasterPos4sv)
GLAPI_FUNC(glReadBuffer)
GLAPI_FUNC(glReadPixels)
GLAPI_FUNC(glRectd)
GLAPI_FUNC(glRectdv)
GLAPI_FUNC(glRectf)
GLAPI_FUNC(glRectfv)
GLAPI_FUNC(glRecti)
GLAPI_FUNC(glRectiv)
GLAPI_FUNC(glRects)
GLAPI_FUNC(glRectsv)
GLAPI_FUNC(glRenderMode)
GLAPI_FUNC(glRotated)
GLAPI_FUNC(glRotatef)
GLAPI_FUNC(glScaled)
GLAPI_FUNC(glScalef)
GLAPI_FUNC(glScissor)
GLAPI_FUNC(glSelectBuffer)
GLAPI_FUNC(glShadeModel)
GLAPI_FUNC(glStencilFunc)
GLAPI_FUNC(glStencilMask)
GLAPI_FUNC(glStencilOp)
GLAPI_FUNC(glTexCoord1d)
GLAPI_FUNC(glTexCoord1dv)
GLAPI_FUNC(glTexCoord1f)
GLAPI_FUNC(glTexCoord1fv)
GLAPI_FUNC(glTexCoord1i)
GLAPI_FUNC(glTexCoord1iv)
GLAPI_FUNC(glTexCoord1s)
GLAPI_FUNC(glTexCoord1sv)
GLAPI_FUNC(glTexCoord2d)
GLAPI_FUNC(glTexCoord2dv)
GLAPI_FUNC(glTexCoord2f)
GLAPI_FUNC(glTexCoord2fv)
GLAPI_FUNC(glTexCoord2i)
GLAPI_FUNC(glTexCoord2iv)
GLAPI_FUNC(glTexCoord2s)
GLAPI_FUNC(glTexCoord2sv)
GLAPI_FUNC(glTexCoord3d)
GLAPI_FUNC(glTexCoord3dv)
GLAPI_FUNC(glTexCoord3f)
GLAPI_FUNC(glTexCoord3fv)
GLAPI_FUNC(glTexCoord3i)
GLAPI_FUNC(glTexCoord3iv)
GLAPI_FUNC(glTexCoord3s)
GLAPI_FUNC(glTexCoord3sv)
GLAPI_FUNC(glTexCoord4d)
GLAPI_FUNC(glTexCoord4dv)
GLAPI_FUNC(glTexCoord4f)
GLAPI_FUNC(glTexCoord4fv)
GLAPI_FUNC(glTexCoord4i)
GLAPI_FUNC(glTexCoord4iv)
GLAPI_FUNC(glTexCoord4s)
GLAPI_FUNC(glTexCoord4sv)
GLAPI_FUNC(glTexCoordPointer)
GLAPI_FUNC(glTexEnvf)
GLAPI_FUNC(glTexEnvfv)
GLAPI_FUNC(glTexEnvi)
GLAPI_FUNC(glTexEnviv)
GLAPI_FUNC(glTexGend)
GLAPI_FUNC(glTexGendv)
GLAPI_FUNC(glTexGenf)
GLAPI_FUNC(glTexGenfv)
GLAPI_FUNC(glTexGeni)
GLAPI_FUNC(glTexGeniv)
GLAPI_FUNC(glTexImage1D)
GLAPI_FUNC(glTexImage2D)
GLAPI_FUNC(glTexParameterf)
GLAPI_FUNC(glTexParameterfv)
GLAPI_FUNC(glTexParameteri)
GLAPI_FUNC(glTexParameteriv)
GLAPI_FUNC(glTexSubImage1D)
GLAPI_FUNC(glTexSubImage2D)
GLAPI_FUNC(glTranslated)
GLAPI_FUNC(glTranslatef)
GLAPI_FUNC(glVertex2d)
GLAPI_FUNC(glVertex2dv)
GLAPI_FUNC(glVertex2f)
GLAPI_FUNC(glVertex2fv)
GLAPI_FUNC(glVertex2i)
GLAPI_FUNC(glVertex2iv)
GLAPI_FUNC(glVertex2s)
GLAPI_FUNC(glVertex2sv)
GLAPI_FUNC(glVertex3d)
GLAPI_FUNC(glVertex3dv)
GLAPI_FUNC(glVertex3f)
GLAPI_FUNC(glVertex3fv)
GLAPI_FUNC(glVertex3i)
GLAPI_FUNC(glVertex3iv)
GLAPI_FUNC(glVertex3s)
GLAPI_FUNC(glVertex3sv)
GLAPI_FUNC(glVertex4d)
GLAPI_FUNC(glVertex4dv)
GLAPI_FUNC(glVertex4f)
GLAPI_FUNC(glVertex4fv)
GLAPI_FUNC(glVertex4i)
GLAPI_FUNC(glVertex4iv)
GLAPI_FUNC(glVertex4s)
GLAPI_FUNC(glVertex4sv)
GLAPI_FUNC(glVertexPointer)
GLAPI_FUNC(glViewport)
#else
#define LOADGLAPI(function) function = (api_##function)wglGetProcAddress(#function);if(!function)puts("0 = "#function);
#endif

/*GL_VERSION_1_2*/
GLAPI_FUNC(glCopyTexSubImage3D)
GLAPI_FUNC(glDrawRangeElements)
GLAPI_FUNC(glTexImage3D)
GLAPI_FUNC(glTexSubImage3D)


/*GL_VERSION_1_3*/
GLAPI_FUNC(glActiveTexture)
GLAPI_FUNC(glClientActiveTexture)
GLAPI_FUNC(glCompressedTexImage1D)
GLAPI_FUNC(glCompressedTexImage2D)
GLAPI_FUNC(glCompressedTexImage3D)
GLAPI_FUNC(glCompressedTexSubImage1D)
GLAPI_FUNC(glCompressedTexSubImage2D)
GLAPI_FUNC(glCompressedTexSubImage3D)
GLAPI_FUNC(glGetCompressedTexImage)
GLAPI_FUNC(glLoadTransposeMatrixd)
GLAPI_FUNC(glLoadTransposeMatrixf)
GLAPI_FUNC(glMultTransposeMatrixd)
GLAPI_FUNC(glMultTransposeMatrixf)
GLAPI_FUNC(glMultiTexCoord1d)
GLAPI_FUNC(glMultiTexCoord1dv)
GLAPI_FUNC(glMultiTexCoord1f)
GLAPI_FUNC(glMultiTexCoord1fv)
GLAPI_FUNC(glMultiTexCoord1i)
GLAPI_FUNC(glMultiTexCoord1iv)
GLAPI_FUNC(glMultiTexCoord1s)
GLAPI_FUNC(glMultiTexCoord1sv)
GLAPI_FUNC(glMultiTexCoord2d)
GLAPI_FUNC(glMultiTexCoord2dv)
GLAPI_FUNC(glMultiTexCoord2f)
GLAPI_FUNC(glMultiTexCoord2fv)
GLAPI_FUNC(glMultiTexCoord2i)
GLAPI_FUNC(glMultiTexCoord2iv)
GLAPI_FUNC(glMultiTexCoord2s)
GLAPI_FUNC(glMultiTexCoord2sv)
GLAPI_FUNC(glMultiTexCoord3d)
GLAPI_FUNC(glMultiTexCoord3dv)
GLAPI_FUNC(glMultiTexCoord3f)
GLAPI_FUNC(glMultiTexCoord3fv)
GLAPI_FUNC(glMultiTexCoord3i)
GLAPI_FUNC(glMultiTexCoord3iv)
GLAPI_FUNC(glMultiTexCoord3s)
GLAPI_FUNC(glMultiTexCoord3sv)
GLAPI_FUNC(glMultiTexCoord4d)
GLAPI_FUNC(glMultiTexCoord4dv)
GLAPI_FUNC(glMultiTexCoord4f)
GLAPI_FUNC(glMultiTexCoord4fv)
GLAPI_FUNC(glMultiTexCoord4i)
GLAPI_FUNC(glMultiTexCoord4iv)
GLAPI_FUNC(glMultiTexCoord4s)
GLAPI_FUNC(glMultiTexCoord4sv)
GLAPI_FUNC(glSampleCoverage)

/*GL_VERSION_1_4*/
GLAPI_FUNC(glBlendColor)
GLAPI_FUNC(glBlendEquation)
GLAPI_FUNC(glBlendFuncSeparate)
GLAPI_FUNC(glFogCoordPointer)
GLAPI_FUNC(glFogCoordd)
GLAPI_FUNC(glFogCoorddv)
GLAPI_FUNC(glFogCoordf)
GLAPI_FUNC(glFogCoordfv)
GLAPI_FUNC(glMultiDrawArrays)
GLAPI_FUNC(glMultiDrawElements)
GLAPI_FUNC(glPointParameterf)
GLAPI_FUNC(glPointParameterfv)
GLAPI_FUNC(glPointParameteri)
GLAPI_FUNC(glPointParameteriv)
GLAPI_FUNC(glSecondaryColor3b)
GLAPI_FUNC(glSecondaryColor3bv)
GLAPI_FUNC(glSecondaryColor3d)
GLAPI_FUNC(glSecondaryColor3dv)
GLAPI_FUNC(glSecondaryColor3f)
GLAPI_FUNC(glSecondaryColor3fv)
GLAPI_FUNC(glSecondaryColor3i)
GLAPI_FUNC(glSecondaryColor3iv)
GLAPI_FUNC(glSecondaryColor3s)
GLAPI_FUNC(glSecondaryColor3sv)
GLAPI_FUNC(glSecondaryColor3ub)
GLAPI_FUNC(glSecondaryColor3ubv)
GLAPI_FUNC(glSecondaryColor3ui)
GLAPI_FUNC(glSecondaryColor3uiv)
GLAPI_FUNC(glSecondaryColor3us)
GLAPI_FUNC(glSecondaryColor3usv)
GLAPI_FUNC(glSecondaryColorPointer)
GLAPI_FUNC(glWindowPos2d)
GLAPI_FUNC(glWindowPos2dv)
GLAPI_FUNC(glWindowPos2f)
GLAPI_FUNC(glWindowPos2fv)
GLAPI_FUNC(glWindowPos2i)
GLAPI_FUNC(glWindowPos2iv)
GLAPI_FUNC(glWindowPos2s)
GLAPI_FUNC(glWindowPos2sv)
GLAPI_FUNC(glWindowPos3d)
GLAPI_FUNC(glWindowPos3dv)
GLAPI_FUNC(glWindowPos3f)
GLAPI_FUNC(glWindowPos3fv)
GLAPI_FUNC(glWindowPos3i)
GLAPI_FUNC(glWindowPos3iv)
GLAPI_FUNC(glWindowPos3s)
GLAPI_FUNC(glWindowPos3sv)

/*GL_VERSION_1_5*/
GLAPI_FUNC(glBeginQuery)
GLAPI_FUNC(glBindBuffer)
GLAPI_FUNC(glBufferData)
GLAPI_FUNC(glBufferSubData)
GLAPI_FUNC(glDeleteBuffers)
GLAPI_FUNC(glDeleteQueries)
GLAPI_FUNC(glEndQuery)
GLAPI_FUNC(glGenBuffers)
GLAPI_FUNC(glGenQueries)
GLAPI_FUNC(glGetBufferParameteriv)
GLAPI_FUNC(glGetBufferPointerv)
GLAPI_FUNC(glGetBufferSubData)
GLAPI_FUNC(glGetQueryObjectiv)
GLAPI_FUNC(glGetQueryObjectuiv)
GLAPI_FUNC(glGetQueryiv)
GLAPI_FUNC(glIsBuffer)
GLAPI_FUNC(glIsQuery)
GLAPI_FUNC(glMapBuffer)
GLAPI_FUNC(glUnmapBuffer)

/*GL_VERSION_2_0*/
GLAPI_FUNC(glAttachShader)
GLAPI_FUNC(glBindAttribLocation)
GLAPI_FUNC(glBlendEquationSeparate)
GLAPI_FUNC(glCompileShader)
GLAPI_FUNC(glCreateProgram)
GLAPI_FUNC(glCreateShader)
GLAPI_FUNC(glDeleteProgram)
GLAPI_FUNC(glDeleteShader)
GLAPI_FUNC(glDetachShader)
GLAPI_FUNC(glDisableVertexAttribArray)
GLAPI_FUNC(glDrawBuffers)
GLAPI_FUNC(glEnableVertexAttribArray)
GLAPI_FUNC(glGetActiveAttrib)
GLAPI_FUNC(glGetActiveUniform)
GLAPI_FUNC(glGetAttachedShaders)
GLAPI_FUNC(glGetAttribLocation)
GLAPI_FUNC(glGetProgramInfoLog)
GLAPI_FUNC(glGetProgramiv)
GLAPI_FUNC(glGetShaderInfoLog)
GLAPI_FUNC(glGetShaderSource)
GLAPI_FUNC(glGetShaderiv)
GLAPI_FUNC(glGetUniformLocation)
GLAPI_FUNC(glGetUniformfv)
GLAPI_FUNC(glGetUniformiv)
GLAPI_FUNC(glGetVertexAttribPointerv)
GLAPI_FUNC(glGetVertexAttribdv)
GLAPI_FUNC(glGetVertexAttribfv)
GLAPI_FUNC(glGetVertexAttribiv)
GLAPI_FUNC(glIsProgram)
GLAPI_FUNC(glIsShader)
GLAPI_FUNC(glLinkProgram)
GLAPI_FUNC(glShaderSource)
GLAPI_FUNC(glStencilFuncSeparate)
GLAPI_FUNC(glStencilMaskSeparate)
GLAPI_FUNC(glStencilOpSeparate)

GLAPI_FUNC(glUniform1f)
GLAPI_FUNC(glUniform1fv)
GLAPI_FUNC(glUniform1i)
GLAPI_FUNC(glUniform1iv)
GLAPI_FUNC(glUniform2f)
GLAPI_FUNC(glUniform2fv)
GLAPI_FUNC(glUniform2i)
GLAPI_FUNC(glUniform2iv)
GLAPI_FUNC(glUniform3f)
GLAPI_FUNC(glUniform3fv)
GLAPI_FUNC(glUniform3i)
GLAPI_FUNC(glUniform3iv)
GLAPI_FUNC(glUniform4f)
GLAPI_FUNC(glUniform4fv)
GLAPI_FUNC(glUniform4i)
GLAPI_FUNC(glUniform4iv)
GLAPI_FUNC(glUniform1d)
GLAPI_FUNC(glUniform2d)
GLAPI_FUNC(glUniform3d)
GLAPI_FUNC(glUniform4d)
GLAPI_FUNC(glUniform1dv)
GLAPI_FUNC(glUniform2dv)
GLAPI_FUNC(glUniform3dv)
GLAPI_FUNC(glUniform4dv)

GLAPI_FUNC(glUniformMatrix2fv)
GLAPI_FUNC(glUniformMatrix3fv)
GLAPI_FUNC(glUniformMatrix4fv)
GLAPI_FUNC(glUseProgram)
GLAPI_FUNC(glValidateProgram)
GLAPI_FUNC(glVertexAttrib1d)
GLAPI_FUNC(glVertexAttrib1dv)
GLAPI_FUNC(glVertexAttrib1f)
GLAPI_FUNC(glVertexAttrib1fv)
GLAPI_FUNC(glVertexAttrib1s)
GLAPI_FUNC(glVertexAttrib1sv)
GLAPI_FUNC(glVertexAttrib2d)
GLAPI_FUNC(glVertexAttrib2dv)
GLAPI_FUNC(glVertexAttrib2f)
GLAPI_FUNC(glVertexAttrib2fv)
GLAPI_FUNC(glVertexAttrib2s)
GLAPI_FUNC(glVertexAttrib2sv)
GLAPI_FUNC(glVertexAttrib3d)
GLAPI_FUNC(glVertexAttrib3dv)
GLAPI_FUNC(glVertexAttrib3f)
GLAPI_FUNC(glVertexAttrib3fv)
GLAPI_FUNC(glVertexAttrib3s)
GLAPI_FUNC(glVertexAttrib3sv)
GLAPI_FUNC(glVertexAttrib4Nbv)
GLAPI_FUNC(glVertexAttrib4Niv)
GLAPI_FUNC(glVertexAttrib4Nsv)
GLAPI_FUNC(glVertexAttrib4Nub)
GLAPI_FUNC(glVertexAttrib4Nubv)
GLAPI_FUNC(glVertexAttrib4Nuiv)
GLAPI_FUNC(glVertexAttrib4Nusv)
GLAPI_FUNC(glVertexAttrib4bv)
GLAPI_FUNC(glVertexAttrib4d)
GLAPI_FUNC(glVertexAttrib4dv)
GLAPI_FUNC(glVertexAttrib4f)
GLAPI_FUNC(glVertexAttrib4fv)
GLAPI_FUNC(glVertexAttrib4iv)
GLAPI_FUNC(glVertexAttrib4s)
GLAPI_FUNC(glVertexAttrib4sv)
GLAPI_FUNC(glVertexAttrib4ubv)
GLAPI_FUNC(glVertexAttrib4uiv)
GLAPI_FUNC(glVertexAttrib4usv)
GLAPI_FUNC(glVertexAttribPointer)

/*GL_VERSION_2_1*/
GLAPI_FUNC(glUniformMatrix2x3fv)
GLAPI_FUNC(glUniformMatrix2x4fv)
GLAPI_FUNC(glUniformMatrix3x2fv)
GLAPI_FUNC(glUniformMatrix3x4fv)
GLAPI_FUNC(glUniformMatrix4x2fv)
GLAPI_FUNC(glUniformMatrix4x3fv)

/*GL_VERSION_3_0*/
GLAPI_FUNC(glBeginConditionalRender)
GLAPI_FUNC(glBeginTransformFeedback)
GLAPI_FUNC(glBindFragDataLocation)
GLAPI_FUNC(glClampColor)
GLAPI_FUNC(glClearBufferfi)
GLAPI_FUNC(glClearBufferfv)
GLAPI_FUNC(glClearBufferiv)
GLAPI_FUNC(glClearBufferuiv)
GLAPI_FUNC(glColorMaski)
GLAPI_FUNC(glDisablei)
GLAPI_FUNC(glEnablei)
GLAPI_FUNC(glEndConditionalRender)
GLAPI_FUNC(glEndTransformFeedback)
GLAPI_FUNC(glGetBooleani_v)
GLAPI_FUNC(glGetFragDataLocation)
GLAPI_FUNC(glGetStringi)
GLAPI_FUNC(glGetTexParameterIiv)
GLAPI_FUNC(glGetTexParameterIuiv)
GLAPI_FUNC(glGetTransformFeedbackVarying)
GLAPI_FUNC(glGetUniformuiv)
GLAPI_FUNC(glGetVertexAttribIiv)
GLAPI_FUNC(glGetVertexAttribIuiv)
GLAPI_FUNC(glIsEnabledi)
GLAPI_FUNC(glTexParameterIiv)
GLAPI_FUNC(glTexParameterIuiv)
GLAPI_FUNC(glTransformFeedbackVaryings)
GLAPI_FUNC(glUniform1ui)
GLAPI_FUNC(glUniform1uiv)
GLAPI_FUNC(glUniform2ui)
GLAPI_FUNC(glUniform2uiv)
GLAPI_FUNC(glUniform3ui)
GLAPI_FUNC(glUniform3uiv)
GLAPI_FUNC(glUniform4ui)
GLAPI_FUNC(glUniform4uiv)
GLAPI_FUNC(glVertexAttribI1i)
GLAPI_FUNC(glVertexAttribI1iv)
GLAPI_FUNC(glVertexAttribI1ui)
GLAPI_FUNC(glVertexAttribI1uiv)
GLAPI_FUNC(glVertexAttribI2i)
GLAPI_FUNC(glVertexAttribI2iv)
GLAPI_FUNC(glVertexAttribI2ui)
GLAPI_FUNC(glVertexAttribI2uiv)
GLAPI_FUNC(glVertexAttribI3i)
GLAPI_FUNC(glVertexAttribI3iv)
GLAPI_FUNC(glVertexAttribI3ui)
GLAPI_FUNC(glVertexAttribI3uiv)
GLAPI_FUNC(glVertexAttribI4bv)
GLAPI_FUNC(glVertexAttribI4i)
GLAPI_FUNC(glVertexAttribI4iv)
GLAPI_FUNC(glVertexAttribI4sv)
GLAPI_FUNC(glVertexAttribI4ubv)
GLAPI_FUNC(glVertexAttribI4ui)
GLAPI_FUNC(glVertexAttribI4uiv)
GLAPI_FUNC(glVertexAttribI4usv)
GLAPI_FUNC(glVertexAttribIPointer)

/*GL_VERSION_3_1*/
GLAPI_FUNC(glDrawArraysInstanced)
GLAPI_FUNC(glDrawElementsInstanced)
GLAPI_FUNC(glPrimitiveRestartIndex)
GLAPI_FUNC(glTexBuffer)

/*GL_VERSION_3_2*/
GLAPI_FUNC(glFramebufferTexture)
GLAPI_FUNC(glGetBufferParameteri64v)
GLAPI_FUNC(glGetInteger64i_v)

/*GL_VERSION_3_3*/
GLAPI_FUNC(glVertexAttribDivisor)

/*GL_VERSION_4_0*/
GLAPI_FUNC(glBlendEquationSeparatei)
GLAPI_FUNC(glBlendEquationi)
GLAPI_FUNC(glBlendFuncSeparatei)
GLAPI_FUNC(glBlendFunci)
GLAPI_FUNC(glMinSampleShading)

/*GL_VERSION_4_2*/

/*GL_VERSION_4_3*/

/*GL_VERSION_4_4*/

/*GL_VERSION_4_5*/

/*GL_VERSION_4_6*/
GLAPI_FUNC(glSpecializeShader)

/*Framebuffer_Object*/
GLAPI_FUNC(glBindFramebuffer)
GLAPI_FUNC(glBindRenderbuffer)
GLAPI_FUNC(glBlitFramebuffer)
GLAPI_FUNC(glCheckFramebufferStatus)
GLAPI_FUNC(glDeleteFramebuffers)
GLAPI_FUNC(glDeleteRenderbuffers)
GLAPI_FUNC(glFramebufferRenderbuffer)
GLAPI_FUNC(glFramebufferTexture1D)
GLAPI_FUNC(glFramebufferTexture2D)
GLAPI_FUNC(glFramebufferTexture3D)
GLAPI_FUNC(glFramebufferTextureLayer)
GLAPI_FUNC(glGenFramebuffers)
GLAPI_FUNC(glGenRenderbuffers)
GLAPI_FUNC(glGenerateMipmap)
GLAPI_FUNC(glGetFramebufferAttachmentParameteriv)
GLAPI_FUNC(glGetRenderbufferParameteriv)
GLAPI_FUNC(glIsFramebuffer)
GLAPI_FUNC(glIsRenderbuffer)
GLAPI_FUNC(glRenderbufferStorage)
GLAPI_FUNC(glRenderbufferStorageMultisample)

void BOpenGL::Init()
{
	static bool inited = false;
	if (inited)
		return;
	/*GL_BASE_VERSION
	LOADGLAPI(glAccum)
	LOADGLAPI(glAlphaFunc)
	LOADGLAPI(glAreTexturesResident)
	LOADGLAPI(glArrayElement)
	LOADGLAPI(glBegin)
	LOADGLAPI(glBindTexture)
	LOADGLAPI(glBitmap)
	LOADGLAPI(glBlendFunc)
	LOADGLAPI(glCallList)
	LOADGLAPI(glCallLists)
	LOADGLAPI(glClear)
	LOADGLAPI(glClearAccum)
	LOADGLAPI(glClearColor)
	LOADGLAPI(glClearDepth)
	LOADGLAPI(glClearIndex)
	LOADGLAPI(glClearStencil)
	LOADGLAPI(glClipPlane)
	LOADGLAPI(glColor3b)
	LOADGLAPI(glColor3bv)
	LOADGLAPI(glColor3d)
	LOADGLAPI(glColor3dv)
	LOADGLAPI(glColor3f)
	LOADGLAPI(glColor3fv)
	LOADGLAPI(glColor3i)
	LOADGLAPI(glColor3iv)
	LOADGLAPI(glColor3s)
	LOADGLAPI(glColor3sv)
	LOADGLAPI(glColor3ub)
	LOADGLAPI(glColor3ubv)
	LOADGLAPI(glColor3ui)
	LOADGLAPI(glColor3uiv)
	LOADGLAPI(glColor3us)
	LOADGLAPI(glColor3usv)
	LOADGLAPI(glColor4b)
	LOADGLAPI(glColor4bv)
	LOADGLAPI(glColor4d)
	LOADGLAPI(glColor4dv)
	LOADGLAPI(glColor4b)
	LOADGLAPI(glColor4fv)
	LOADGLAPI(glColor4i)
	LOADGLAPI(glColor4iv)
	LOADGLAPI(glColor4s)
	LOADGLAPI(glColor4sv)
	LOADGLAPI(glColor4ub)
	LOADGLAPI(glColor4ubv)
	LOADGLAPI(glColor4ui)
	LOADGLAPI(glColor4uiv)
	LOADGLAPI(glColor4us)
	LOADGLAPI(glColor4usv)
	LOADGLAPI(glColorMask)
	LOADGLAPI(glColorMaterial)
	LOADGLAPI(glColorPointer)
	LOADGLAPI(glCopyPixels)
	LOADGLAPI(glCopyTexImage1D)
	LOADGLAPI(glCopyTexImage2D)
	LOADGLAPI(glCopyTexSubImage1D)
	LOADGLAPI(glCopyTexSubImage2D)
	LOADGLAPI(glCullFace)
	LOADGLAPI(glDeleteLists)
	LOADGLAPI(glDeleteTextures)
	LOADGLAPI(glDepthFunc)
	LOADGLAPI(glDepthMask)
	LOADGLAPI(glDepthRange)
	LOADGLAPI(glDisable)
	LOADGLAPI(glDisableClientState)
	LOADGLAPI(glDrawArrays)
	LOADGLAPI(glDrawBuffer)
	LOADGLAPI(glDrawElements)
	LOADGLAPI(glDrawPixels)
	LOADGLAPI(glEdgeFlag)
	LOADGLAPI(glEdgeFlagPointer)
	LOADGLAPI(glEdgeFlagv)
	LOADGLAPI(glEnable)
	LOADGLAPI(glEnableClientState)
	LOADGLAPI(glEnd)
	LOADGLAPI(glEndList)
	LOADGLAPI(glEvalCoord1d)
	LOADGLAPI(glEvalCoord1dv)
	LOADGLAPI(glEvalCoord1f)
	LOADGLAPI(glEvalCoord1fv)
	LOADGLAPI(glEvalCoord2d)
	LOADGLAPI(glEvalCoord2dv)
	LOADGLAPI(glEvalCoord2f)
	LOADGLAPI(glEvalCoord2fv)
	LOADGLAPI(glEvalMesh1)
	LOADGLAPI(glEvalMesh2)
	LOADGLAPI(glEvalPoint1)
	LOADGLAPI(glEvalPoint2)
	LOADGLAPI(glFeedbackBuffer)
	LOADGLAPI(glFinish)
	LOADGLAPI(glFlush)
	LOADGLAPI(glFogf)
	LOADGLAPI(glFogfv)
	LOADGLAPI(glFogi)
	LOADGLAPI(glFogiv)
	LOADGLAPI(glFrontFace)
	LOADGLAPI(glFrustum)
	LOADGLAPI(glGenLists)
	LOADGLAPI(glGenTextures)
	LOADGLAPI(glGetBooleanv)
	LOADGLAPI(glGetClipPlane)
	LOADGLAPI(glGetDoublev)
	LOADGLAPI(glGetError)
	LOADGLAPI(glGetFloatv)
	LOADGLAPI(glGetIntegerv)
	LOADGLAPI(glGetLightfv)
	LOADGLAPI(glGetLightiv)
	LOADGLAPI(glGetMapdv)
	LOADGLAPI(glGetMapfv)
	LOADGLAPI(glGetMapiv)
	LOADGLAPI(glGetMaterialfv)
	LOADGLAPI(glGetMaterialiv)
	LOADGLAPI(glGetPixelMapfv)
	LOADGLAPI(glGetPixelMapuiv)
	LOADGLAPI(glGetPixelMapusv)
	LOADGLAPI(glGetPointerv)
	LOADGLAPI(glGetPolygonStipple)
	LOADGLAPI(glGetString)
	LOADGLAPI(glGetTexEnvfv)
	LOADGLAPI(glGetTexEnviv)
	LOADGLAPI(glGetTexGendv)
	LOADGLAPI(glGetTexGenfv)
	LOADGLAPI(glGetTexGeniv)
	LOADGLAPI(glGetTexImage)
	LOADGLAPI(glGetTexLevelParameterfv)
	LOADGLAPI(glGetTexLevelParameteriv)
	LOADGLAPI(glGetTexParameterfv)
	LOADGLAPI(glGetTexParameteriv)
	LOADGLAPI(glHint)
	LOADGLAPI(glIndexMask)
	LOADGLAPI(glIndexPointer)
	LOADGLAPI(glIndexd)
	LOADGLAPI(glIndexdv)
	LOADGLAPI(glIndexf)
	LOADGLAPI(glIndexfv)
	LOADGLAPI(glIndexi)
	LOADGLAPI(glIndexiv)
	LOADGLAPI(glIndexs)
	LOADGLAPI(glIndexsv)
	LOADGLAPI(glIndexub)
	LOADGLAPI(glIndexubv)
	LOADGLAPI(glInitNames)
	LOADGLAPI(glInterleavedArrays)
	LOADGLAPI(glIsEnabled)
	LOADGLAPI(glIsList)
	LOADGLAPI(glIsTexture)
	LOADGLAPI(glLightModelf)
	LOADGLAPI(glLightModelfv)
	LOADGLAPI(glLightModeli)
	LOADGLAPI(glLightModeliv)
	LOADGLAPI(glLightf)
	LOADGLAPI(glLightfv)
	LOADGLAPI(glLighti)
	LOADGLAPI(glLightiv)
	LOADGLAPI(glLineStipple)
	LOADGLAPI(glLineWidth)
	LOADGLAPI(glListBase)
	LOADGLAPI(glLoadIdentity)
	LOADGLAPI(glLoadMatrixd)
	LOADGLAPI(glLoadMatrixf)
	LOADGLAPI(glLoadName)
	LOADGLAPI(glLogicOp)
	LOADGLAPI(glMap1d)
	LOADGLAPI(glMap1f)
	LOADGLAPI(glMap2d)
	LOADGLAPI(glMap2f)
	LOADGLAPI(glMapGrid1d)
	LOADGLAPI(glMapGrid1f)
	LOADGLAPI(glMapGrid2d)
	LOADGLAPI(glMapGrid2f)
	LOADGLAPI(glMaterialf)
	LOADGLAPI(glMaterialfv)
	LOADGLAPI(glMateriali)
	LOADGLAPI(glMaterialiv)
	LOADGLAPI(glMatrixMode)
	LOADGLAPI(glMultMatrixd)
	LOADGLAPI(glMultMatrixf)
	LOADGLAPI(glNewList)
	LOADGLAPI(glNormal3b)
	LOADGLAPI(glNormal3bv)
	LOADGLAPI(glNormal3d)
	LOADGLAPI(glNormal3dv)
	LOADGLAPI(glNormal3f)
	LOADGLAPI(glNormal3fv)
	LOADGLAPI(glNormal3i)
	LOADGLAPI(glNormal3iv)
	LOADGLAPI(glNormal3s)
	LOADGLAPI(glNormal3sv)
	LOADGLAPI(glNormalPointer)
	LOADGLAPI(glOrtho)
	LOADGLAPI(glPassThrough)
	LOADGLAPI(glPixelMapfv)
	LOADGLAPI(glPixelMapuiv)
	LOADGLAPI(glPixelMapusv)
	LOADGLAPI(glPixelStoref)
	LOADGLAPI(glPixelStorei)
	LOADGLAPI(glPixelTransferf)
	LOADGLAPI(glPixelTransferi)
	LOADGLAPI(glPixelZoom)
	LOADGLAPI(glPointSize)
	LOADGLAPI(glPolygonMode)
	LOADGLAPI(glPolygonOffset)
	LOADGLAPI(glPolygonStipple)
	LOADGLAPI(glPopAttrib)
	LOADGLAPI(glPopClientAttrib)
	LOADGLAPI(glPopMatrix)
	LOADGLAPI(glPopName)
	LOADGLAPI(glPrioritizeTextures)
	LOADGLAPI(glPushAttrib)
	LOADGLAPI(glPushClientAttrib)
	LOADGLAPI(glPushMatrix)
	LOADGLAPI(glPushName)
	LOADGLAPI(glRasterPos2d)
	LOADGLAPI(glRasterPos2dv)
	LOADGLAPI(glRasterPos2f)
	LOADGLAPI(glRasterPos2fv)
	LOADGLAPI(glRasterPos2i)
	LOADGLAPI(glRasterPos2iv)
	LOADGLAPI(glRasterPos2s)
	LOADGLAPI(glRasterPos2sv)
	LOADGLAPI(glRasterPos3d)
	LOADGLAPI(glRasterPos3dv)
	LOADGLAPI(glRasterPos3f)
	LOADGLAPI(glRasterPos3fv)
	LOADGLAPI(glRasterPos3i)
	LOADGLAPI(glRasterPos3iv)
	LOADGLAPI(glRasterPos3s)
	LOADGLAPI(glRasterPos3sv)
	LOADGLAPI(glRasterPos4d)
	LOADGLAPI(glRasterPos4dv)
	LOADGLAPI(glRasterPos4f)
	LOADGLAPI(glRasterPos4fv)
	LOADGLAPI(glRasterPos4i)
	LOADGLAPI(glRasterPos4iv)
	LOADGLAPI(glRasterPos4s)
	LOADGLAPI(glRasterPos4sv)
	LOADGLAPI(glReadBuffer)
	LOADGLAPI(glReadPixels)
	LOADGLAPI(glRectd)
	LOADGLAPI(glRectdv)
	LOADGLAPI(glRectf)
	LOADGLAPI(glRectfv)
	LOADGLAPI(glRecti)
	LOADGLAPI(glRectiv)
	LOADGLAPI(glRects)
	LOADGLAPI(glRectsv)
	LOADGLAPI(glRenderMode)
	LOADGLAPI(glRotated)
	LOADGLAPI(glRotatef)
	LOADGLAPI(glScaled)
	LOADGLAPI(glScalef)
	LOADGLAPI(glScissor)
	LOADGLAPI(glSelectBuffer)
	LOADGLAPI(glShadeModel)
	LOADGLAPI(glStencilFunc)
	LOADGLAPI(glStencilMask)
	LOADGLAPI(glStencilOp)
	LOADGLAPI(glTexCoord1d)
	LOADGLAPI(glTexCoord1dv)
	LOADGLAPI(glTexCoord1f)
	LOADGLAPI(glTexCoord1fv)
	LOADGLAPI(glTexCoord1i)
	LOADGLAPI(glTexCoord1iv)
	LOADGLAPI(glTexCoord1s)
	LOADGLAPI(glTexCoord1sv)
	LOADGLAPI(glTexCoord2d)
	LOADGLAPI(glTexCoord2dv)
	LOADGLAPI(glTexCoord2f)
	LOADGLAPI(glTexCoord2fv)
	LOADGLAPI(glTexCoord2i)
	LOADGLAPI(glTexCoord2iv)
	LOADGLAPI(glTexCoord2s)
	LOADGLAPI(glTexCoord2sv)
	LOADGLAPI(glTexCoord3d)
	LOADGLAPI(glTexCoord3dv)
	LOADGLAPI(glTexCoord3f)
	LOADGLAPI(glTexCoord3fv)
	LOADGLAPI(glTexCoord3i)
	LOADGLAPI(glTexCoord3iv)
	LOADGLAPI(glTexCoord3s)
	LOADGLAPI(glTexCoord3sv)
	LOADGLAPI(glTexCoord4d)
	LOADGLAPI(glTexCoord4dv)
	LOADGLAPI(glTexCoord4f)
	LOADGLAPI(glTexCoord4fv)
	LOADGLAPI(glTexCoord4i)
	LOADGLAPI(glTexCoord4iv)
	LOADGLAPI(glTexCoord4s)
	LOADGLAPI(glTexCoord4sv)
	LOADGLAPI(glTexCoordPointer)
	LOADGLAPI(glTexEnvf)
	LOADGLAPI(glTexEnvfv)
	LOADGLAPI(glTexEnvi)
	LOADGLAPI(glTexEnviv)
	LOADGLAPI(glTexGend)
	LOADGLAPI(glTexGendv)
	LOADGLAPI(glTexGenf)
	LOADGLAPI(glTexGenfv)
	LOADGLAPI(glTexGeni)
	LOADGLAPI(glTexGeniv)
	LOADGLAPI(glTexImage1D)
	LOADGLAPI(glTexImage2D)
	LOADGLAPI(glTexParameterf)
	LOADGLAPI(glTexParameterfv)
	LOADGLAPI(glTexParameteri)
	LOADGLAPI(glTexParameteriv)
	LOADGLAPI(glTexSubImage1D)
	LOADGLAPI(glTexSubImage2D)
	LOADGLAPI(glTranslated)
	LOADGLAPI(glTranslatef)
	LOADGLAPI(glVertex2d)
	LOADGLAPI(glVertex2dv)
	LOADGLAPI(glVertex2f)
	LOADGLAPI(glVertex2fv)
	LOADGLAPI(glVertex2i)
	LOADGLAPI(glVertex2iv)
	LOADGLAPI(glVertex2s)
	LOADGLAPI(glVertex2sv)
	LOADGLAPI(glVertex3d)
	LOADGLAPI(glVertex3dv)
	LOADGLAPI(glVertex3f)
	LOADGLAPI(glVertex3fv)
	LOADGLAPI(glVertex3i)
	LOADGLAPI(glVertex3iv)
	LOADGLAPI(glVertex3s)
	LOADGLAPI(glVertex3sv)
	LOADGLAPI(glVertex4d)
	LOADGLAPI(glVertex4dv)
	LOADGLAPI(glVertex4f)
	LOADGLAPI(glVertex4fv)
	LOADGLAPI(glVertex4i)
	LOADGLAPI(glVertex4iv)
	LOADGLAPI(glVertex4s)
	LOADGLAPI(glVertex4sv)
	LOADGLAPI(glVertexPointer)
	LOADGLAPI(glViewport)
	*/
	/*GL_VERSION_1_2*/
	LOADGLAPI(glCopyTexSubImage3D)
	LOADGLAPI(glDrawRangeElements)
	LOADGLAPI(glTexImage3D)
	LOADGLAPI(glTexSubImage3D)

	/*GL_VERSION_1_3*/
	LOADGLAPI(glActiveTexture)
	LOADGLAPI(glClientActiveTexture)
	LOADGLAPI(glCompressedTexImage1D)
	LOADGLAPI(glCompressedTexImage2D)
	LOADGLAPI(glCompressedTexImage3D)
	LOADGLAPI(glCompressedTexSubImage1D)
	LOADGLAPI(glCompressedTexSubImage2D)
	LOADGLAPI(glCompressedTexSubImage3D)
	LOADGLAPI(glGetCompressedTexImage)
	LOADGLAPI(glLoadTransposeMatrixd)
	LOADGLAPI(glLoadTransposeMatrixf)
	LOADGLAPI(glMultTransposeMatrixd)
	LOADGLAPI(glMultTransposeMatrixf)
	LOADGLAPI(glMultiTexCoord1d)
	LOADGLAPI(glMultiTexCoord1dv)
	LOADGLAPI(glMultiTexCoord1f)
	LOADGLAPI(glMultiTexCoord1fv)
	LOADGLAPI(glMultiTexCoord1i)
	LOADGLAPI(glMultiTexCoord1iv)
	LOADGLAPI(glMultiTexCoord1s)
	LOADGLAPI(glMultiTexCoord1sv)
	LOADGLAPI(glMultiTexCoord2d)
	LOADGLAPI(glMultiTexCoord2dv)
	LOADGLAPI(glMultiTexCoord2f)
	LOADGLAPI(glMultiTexCoord2fv)
	LOADGLAPI(glMultiTexCoord2i)
	LOADGLAPI(glMultiTexCoord2iv)
	LOADGLAPI(glMultiTexCoord2s)
	LOADGLAPI(glMultiTexCoord2sv)
	LOADGLAPI(glMultiTexCoord3d)
	LOADGLAPI(glMultiTexCoord3dv)
	LOADGLAPI(glMultiTexCoord3f)
	LOADGLAPI(glMultiTexCoord3fv)
	LOADGLAPI(glMultiTexCoord3i)
	LOADGLAPI(glMultiTexCoord3iv)
	LOADGLAPI(glMultiTexCoord3s)
	LOADGLAPI(glMultiTexCoord3sv)
	LOADGLAPI(glMultiTexCoord4d)
	LOADGLAPI(glMultiTexCoord4dv)
	LOADGLAPI(glMultiTexCoord4f)
	LOADGLAPI(glMultiTexCoord4fv)
	LOADGLAPI(glMultiTexCoord4i)
	LOADGLAPI(glMultiTexCoord4iv)
	LOADGLAPI(glMultiTexCoord4s)
	LOADGLAPI(glMultiTexCoord4sv)
	LOADGLAPI(glSampleCoverage)

	/*GL_VERSION_1_4*/
	LOADGLAPI(glBlendColor)
	LOADGLAPI(glBlendEquation)
	LOADGLAPI(glBlendFuncSeparate)
	LOADGLAPI(glFogCoordPointer)
	LOADGLAPI(glFogCoordd)
	LOADGLAPI(glFogCoorddv)
	LOADGLAPI(glFogCoordf)
	LOADGLAPI(glFogCoordfv)
	LOADGLAPI(glMultiDrawArrays)
	LOADGLAPI(glMultiDrawElements)
	LOADGLAPI(glPointParameterf)
	LOADGLAPI(glPointParameterfv)
	LOADGLAPI(glPointParameteri)
	LOADGLAPI(glPointParameteriv)
	LOADGLAPI(glSecondaryColor3b)
	LOADGLAPI(glSecondaryColor3bv)
	LOADGLAPI(glSecondaryColor3d)
	LOADGLAPI(glSecondaryColor3dv)
	LOADGLAPI(glSecondaryColor3f)
	LOADGLAPI(glSecondaryColor3fv)
	LOADGLAPI(glSecondaryColor3i)
	LOADGLAPI(glSecondaryColor3iv)
	LOADGLAPI(glSecondaryColor3s)
	LOADGLAPI(glSecondaryColor3sv)
	LOADGLAPI(glSecondaryColor3ub)
	LOADGLAPI(glSecondaryColor3ubv)
	LOADGLAPI(glSecondaryColor3ui)
	LOADGLAPI(glSecondaryColor3uiv)
	LOADGLAPI(glSecondaryColor3us)
	LOADGLAPI(glSecondaryColor3usv)
	LOADGLAPI(glSecondaryColorPointer)
	LOADGLAPI(glWindowPos2d)
	LOADGLAPI(glWindowPos2dv)
	LOADGLAPI(glWindowPos2f)
	LOADGLAPI(glWindowPos2fv)
	LOADGLAPI(glWindowPos2i)
	LOADGLAPI(glWindowPos2iv)
	LOADGLAPI(glWindowPos2s)
	LOADGLAPI(glWindowPos2sv)
	LOADGLAPI(glWindowPos3d)
	LOADGLAPI(glWindowPos3dv)
	LOADGLAPI(glWindowPos3f)
	LOADGLAPI(glWindowPos3fv)
	LOADGLAPI(glWindowPos3i)
	LOADGLAPI(glWindowPos3iv)
	LOADGLAPI(glWindowPos3s)
	LOADGLAPI(glWindowPos3sv)

	/*GL_VERSION_1_5*/
	LOADGLAPI(glBeginQuery)
	LOADGLAPI(glBindBuffer)
	LOADGLAPI(glBufferData)
	LOADGLAPI(glBufferSubData)
	LOADGLAPI(glDeleteBuffers)
	LOADGLAPI(glDeleteQueries)
	LOADGLAPI(glEndQuery)
	LOADGLAPI(glGenBuffers)
	LOADGLAPI(glGenQueries)
	LOADGLAPI(glGetBufferParameteriv)
	LOADGLAPI(glGetBufferPointerv)
	LOADGLAPI(glGetBufferSubData)
	LOADGLAPI(glGetQueryObjectiv)
	LOADGLAPI(glGetQueryObjectuiv)
	LOADGLAPI(glGetQueryiv)
	LOADGLAPI(glIsBuffer)
	LOADGLAPI(glIsQuery)
	LOADGLAPI(glMapBuffer)
	LOADGLAPI(glUnmapBuffer)

	/*GL_VERSION_2_0*/
	LOADGLAPI(glAttachShader)
	LOADGLAPI(glBindAttribLocation)
	LOADGLAPI(glBlendEquationSeparate)
	LOADGLAPI(glCompileShader)
	LOADGLAPI(glCreateProgram)
	LOADGLAPI(glCreateShader)
	LOADGLAPI(glDeleteProgram)
	LOADGLAPI(glDeleteShader)
	LOADGLAPI(glDetachShader)
	LOADGLAPI(glDisableVertexAttribArray)
	LOADGLAPI(glDrawBuffers)
	LOADGLAPI(glEnableVertexAttribArray)
	LOADGLAPI(glGetActiveAttrib)
	LOADGLAPI(glGetActiveUniform)
	LOADGLAPI(glGetAttachedShaders)
	LOADGLAPI(glGetAttribLocation)
	LOADGLAPI(glGetProgramInfoLog)
	LOADGLAPI(glGetProgramiv)
	LOADGLAPI(glGetShaderInfoLog)
	LOADGLAPI(glGetShaderSource)
	LOADGLAPI(glGetShaderiv)
	LOADGLAPI(glGetUniformLocation)
	LOADGLAPI(glGetUniformfv)
	LOADGLAPI(glGetUniformiv)
	LOADGLAPI(glGetVertexAttribPointerv)
	LOADGLAPI(glGetVertexAttribdv)
	LOADGLAPI(glGetVertexAttribfv)
	LOADGLAPI(glGetVertexAttribiv)
	LOADGLAPI(glIsProgram)
	LOADGLAPI(glIsShader)
	LOADGLAPI(glLinkProgram)
	LOADGLAPI(glShaderSource)
	LOADGLAPI(glStencilFuncSeparate)
	LOADGLAPI(glStencilMaskSeparate)
	LOADGLAPI(glStencilOpSeparate)

	LOADGLAPI(glUniform1f)
	LOADGLAPI(glUniform1fv)
	LOADGLAPI(glUniform1i)
	LOADGLAPI(glUniform1iv)
	LOADGLAPI(glUniform2f)
	LOADGLAPI(glUniform2fv)
	LOADGLAPI(glUniform2i)
	LOADGLAPI(glUniform2iv)
	LOADGLAPI(glUniform3f)
	LOADGLAPI(glUniform3fv)
	LOADGLAPI(glUniform3i)
	LOADGLAPI(glUniform3iv)
	LOADGLAPI(glUniform4f)
	LOADGLAPI(glUniform4fv)
	LOADGLAPI(glUniform4i)
	LOADGLAPI(glUniform4iv)
	LOADGLAPI(glUniform1d)
	LOADGLAPI(glUniform2d)
	LOADGLAPI(glUniform3d)
	LOADGLAPI(glUniform4d)
	LOADGLAPI(glUniform1dv)
	LOADGLAPI(glUniform2dv)
	LOADGLAPI(glUniform3dv)
	LOADGLAPI(glUniform4dv)
	LOADGLAPI(glUniformMatrix2fv)
	LOADGLAPI(glUniformMatrix3fv)
	LOADGLAPI(glUniformMatrix4fv)

	LOADGLAPI(glUseProgram)
	LOADGLAPI(glValidateProgram)
	LOADGLAPI(glVertexAttrib1d)
	LOADGLAPI(glVertexAttrib1dv)
	LOADGLAPI(glVertexAttrib1f)
	LOADGLAPI(glVertexAttrib1fv)
	LOADGLAPI(glVertexAttrib1s)
	LOADGLAPI(glVertexAttrib1sv)
	LOADGLAPI(glVertexAttrib2d)
	LOADGLAPI(glVertexAttrib2dv)
	LOADGLAPI(glVertexAttrib2f)
	LOADGLAPI(glVertexAttrib2fv)
	LOADGLAPI(glVertexAttrib2s)
	LOADGLAPI(glVertexAttrib2sv)
	LOADGLAPI(glVertexAttrib3d)
	LOADGLAPI(glVertexAttrib3dv)
	LOADGLAPI(glVertexAttrib3f)
	LOADGLAPI(glVertexAttrib3fv)
	LOADGLAPI(glVertexAttrib3s)
	LOADGLAPI(glVertexAttrib3sv)
	LOADGLAPI(glVertexAttrib4Nbv)
	LOADGLAPI(glVertexAttrib4Niv)
	LOADGLAPI(glVertexAttrib4Nsv)
	LOADGLAPI(glVertexAttrib4Nub)
	LOADGLAPI(glVertexAttrib4Nubv)
	LOADGLAPI(glVertexAttrib4Nuiv)
	LOADGLAPI(glVertexAttrib4Nusv)
	LOADGLAPI(glVertexAttrib4bv)
	LOADGLAPI(glVertexAttrib4d)
	LOADGLAPI(glVertexAttrib4dv)
	LOADGLAPI(glVertexAttrib4f)
	LOADGLAPI(glVertexAttrib4fv)
	LOADGLAPI(glVertexAttrib4iv)
	LOADGLAPI(glVertexAttrib4s)
	LOADGLAPI(glVertexAttrib4sv)
	LOADGLAPI(glVertexAttrib4ubv)
	LOADGLAPI(glVertexAttrib4uiv)
	LOADGLAPI(glVertexAttrib4usv)
	LOADGLAPI(glVertexAttribPointer)

	/*GL_VERSION_2_1*/
	LOADGLAPI(glUniformMatrix2x3fv)
	LOADGLAPI(glUniformMatrix2x4fv)
	LOADGLAPI(glUniformMatrix3x2fv)
	LOADGLAPI(glUniformMatrix3x4fv)
	LOADGLAPI(glUniformMatrix4x2fv)
	LOADGLAPI(glUniformMatrix4x3fv)

	/*GL_VERSION_3_0*/
	LOADGLAPI(glBeginConditionalRender)
	LOADGLAPI(glBeginTransformFeedback)
	LOADGLAPI(glBindFragDataLocation)
	LOADGLAPI(glClampColor)
	LOADGLAPI(glClearBufferfi)
	LOADGLAPI(glClearBufferfv)
	LOADGLAPI(glClearBufferiv)
	LOADGLAPI(glClearBufferuiv)
	LOADGLAPI(glColorMaski)
	LOADGLAPI(glDisablei)
	LOADGLAPI(glEnablei)
	LOADGLAPI(glEndConditionalRender)
	LOADGLAPI(glEndTransformFeedback)
	LOADGLAPI(glGetBooleani_v)
	LOADGLAPI(glGetFragDataLocation)
	LOADGLAPI(glGetStringi)
	LOADGLAPI(glGetTexParameterIiv)
	LOADGLAPI(glGetTexParameterIuiv)
	LOADGLAPI(glGetTransformFeedbackVarying)
	LOADGLAPI(glGetUniformuiv)
	LOADGLAPI(glGetVertexAttribIiv)
	LOADGLAPI(glGetVertexAttribIuiv)
	LOADGLAPI(glIsEnabledi)
	LOADGLAPI(glTexParameterIiv)
	LOADGLAPI(glTexParameterIuiv)
	LOADGLAPI(glTransformFeedbackVaryings)
	LOADGLAPI(glUniform1ui)
	LOADGLAPI(glUniform1uiv)
	LOADGLAPI(glUniform2ui)
	LOADGLAPI(glUniform2uiv)
	LOADGLAPI(glUniform3ui)
	LOADGLAPI(glUniform3uiv)
	LOADGLAPI(glUniform4ui)
	LOADGLAPI(glUniform4uiv)
	LOADGLAPI(glVertexAttribI1i)
	LOADGLAPI(glVertexAttribI1iv)
	LOADGLAPI(glVertexAttribI1ui)
	LOADGLAPI(glVertexAttribI1uiv)
	LOADGLAPI(glVertexAttribI2i)
	LOADGLAPI(glVertexAttribI2iv)
	LOADGLAPI(glVertexAttribI2ui)
	LOADGLAPI(glVertexAttribI2uiv)
	LOADGLAPI(glVertexAttribI3i)
	LOADGLAPI(glVertexAttribI3iv)
	LOADGLAPI(glVertexAttribI3ui)
	LOADGLAPI(glVertexAttribI3uiv)
	LOADGLAPI(glVertexAttribI4bv)
	LOADGLAPI(glVertexAttribI4i)
	LOADGLAPI(glVertexAttribI4iv)
	LOADGLAPI(glVertexAttribI4sv)
	LOADGLAPI(glVertexAttribI4ubv)
	LOADGLAPI(glVertexAttribI4ui)
	LOADGLAPI(glVertexAttribI4uiv)
	LOADGLAPI(glVertexAttribI4usv)
	LOADGLAPI(glVertexAttribIPointer)

	/*GL_VERSION_3_1*/
	LOADGLAPI(glDrawArraysInstanced)
	LOADGLAPI(glDrawElementsInstanced)
	LOADGLAPI(glPrimitiveRestartIndex)
	LOADGLAPI(glTexBuffer)

	/*GL_VERSION_3_2*/
	LOADGLAPI(glFramebufferTexture)
	LOADGLAPI(glGetBufferParameteri64v)
	LOADGLAPI(glGetInteger64i_v)

	/*GL_VERSION_3_3*/
	LOADGLAPI(glVertexAttribDivisor)

	/*GL_VERSION_4_0*/
	LOADGLAPI(glBlendEquationSeparatei)
	LOADGLAPI(glBlendEquationi)
	LOADGLAPI(glBlendFuncSeparatei)
	LOADGLAPI(glBlendFunci)
	LOADGLAPI(glMinSampleShading)

	/*GL_VERSION_4_2*/

	/*GL_VERSION_4_3*/

	/*GL_VERSION_4_4*/

	/*GL_VERSION_4_5*/

	/*GL_VERSION_4_6*/
	LOADGLAPI(glSpecializeShader)

	/*Framebuffer_Object*/
	LOADGLAPI(glBindFramebuffer)
	LOADGLAPI(glBindRenderbuffer)
	LOADGLAPI(glBlitFramebuffer)
	LOADGLAPI(glCheckFramebufferStatus)
	LOADGLAPI(glDeleteFramebuffers)
	LOADGLAPI(glDeleteRenderbuffers)
	LOADGLAPI(glFramebufferRenderbuffer)
	LOADGLAPI(glFramebufferTexture1D)
	LOADGLAPI(glFramebufferTexture2D)
	LOADGLAPI(glFramebufferTexture3D)
	LOADGLAPI(glFramebufferTextureLayer)
	LOADGLAPI(glGenFramebuffers)
	LOADGLAPI(glGenRenderbuffers)
	LOADGLAPI(glGenerateMipmap)
	LOADGLAPI(glGetFramebufferAttachmentParameteriv)
	LOADGLAPI(glGetRenderbufferParameteriv)
	LOADGLAPI(glIsFramebuffer)
	LOADGLAPI(glIsRenderbuffer)
	LOADGLAPI(glRenderbufferStorage)
	LOADGLAPI(glRenderbufferStorageMultisample)

	inited = true;
}
bool BOpenGL::Check()
{
	GLenum error = glGetError();
	if (error == GL_NO_ERROR)
		return true;
	switch (error)
	{
	case GL_INVALID_ENUM:
		puts("GLERROR : An unacceptable value is specified for an enumerated argument.The offending command is ignored and has no other side effect than to set the error flag.");
		break;
	case GL_INVALID_VALUE:
		puts("GLERROR : A numeric argument is out of range.The offending command is ignored and has no other side effect than to set the error flag.");
		break;
	case GL_INVALID_OPERATION:
		puts("GLERROR : The specified operation is not allowed in the current state.The offending command is ignored and has no other side effect than to set the error flag.");
		break;
	case GL_INVALID_FRAMEBUFFER_OPERATION:
		puts("GLERROR : The command is trying to render to or read from the framebuffer while the currently bound framebuffer is not framebuffer complete.");
		break;
	case GL_OUT_OF_MEMORY:
		puts("GLERROR : There is not enough memory left to execute the command.The state of the GL is undefined, except for the state of the error flags, after this error is recorded.");
		break;
	default:
		break;
	}
	return false;
}

void BOpenGL::Release()
{
	if (UnusedTextureObjects.size())
	{
		glDeleteTextures(UnusedTextureObjects.size(), UnusedTextureObjects.data());
		UnusedTextureObjects.clear();
	}
	if (UnusedRenderBufferObjects.size())
	{
		glDeleteRenderbuffers(UnusedRenderBufferObjects.size(), UnusedRenderBufferObjects.data());
		UnusedRenderBufferObjects.clear();
	}
	if (UnusedFrameBufferObjects.size())
	{
		glDeleteFramebuffers(UnusedFrameBufferObjects.size(), UnusedFrameBufferObjects.data());
		UnusedFrameBufferObjects.clear();
	}
	if (UnusedProgramObjects.size())
	{
		for (int i = 0; i < UnusedProgramObjects.size(); i++)
		{
			glDeleteProgram(UnusedProgramObjects[i]);
		}
		UnusedProgramObjects.clear();
	}
	if (UnusedListObjects.size())
	{
		for (int i = 0; i < UnusedListObjects.size(); i++)
		{
			glDeleteLists(UnusedListObjects[i], 1);
		}
		UnusedListObjects.clear();
	}
}

BOpenGL::BOpenGL()
{

}
BOpenGL::~BOpenGL()
{

}

BArray<IGLState> StateStack;

void BOpenGL::pushStates()
{
	IGLState state;
	state.save();
	StateStack.push(state);
}
void BOpenGL::popStates()
{
	IGLState state;
	StateStack.pop(state);
	state.open();
}







